﻿using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;

namespace tmAsk.Webs
{
    public partial class install : System.Web.UI.Page
    {
        tmAsk.Data.MakehtmlSQL SQL = new tmAsk.Data.MakehtmlSQL();
        bool isOk = true;
        protected void Page_Load(object sender, EventArgs e)
        {
            string url = Request.Url.ToString();
            if (url.Split('/').Length > 4)
            {
                isOk = false;
                lblPath.Text = "<span style=\"color:red;\">否</span>";
            }
            else
            {
                lblPath.Text = "是";
            }
            string netVer = System.Environment.Version.ToString();
            if (netVer != null)
            {
                lblNetFramework.Text = "支持";
                if (Convert.ToDouble(netVer.Substring(0, 3)) < 2.0)
                {
                    isOk = false;
                    lblNetVer.Text = netVer + " <span style=\"color:red;\">版本过低</span>";
                }
                else
                {
                    lblNetVer.Text = netVer;
                }
            }
            else
            {
                isOk = false;
                lblNetFramework.Text = "<span style=\"color:red;\">不支持</span>";
            }

            bool WriterPermissions = true;

            int id = 0;
            try
            {
                id = SQL.Add("insert into B_admin(a_username,a_userpassword) values('123','123')");
                SQL.ExecuteSql("delete from B_admin where a_id=" + id);
            }
            catch
            {
                WriterPermissions = false;
            }
            if (id < 0)
            {
                WriterPermissions = false;
            }
            if (WriterPermissions)
            {
                lblWriterPermissions.Text = "支持";
            }
            else
            {
                isOk = false;
                lblWriterPermissions.Text = "<span style=\"color:red;\">不支持</span>";
            }

            if (!isOk)
            {
                btnNext.Enabled = false;
            }
        }
        protected void btnNext_Click(object sender, EventArgs e)
        {
            if (isOk)
            {
                Response.Redirect("install_.aspx");
            }
        }
    }
}